<?php

class LoginForm extends sfForm
{
  public function configure()
  {    
    // Tao ma HTML
    $this->setWidgets(array(
      'username' => new sfWidgetFormInput(), 
      'password' => new sfWidgetFormInputPassword() 
    ));

    //  Thay doi labels
    $this->widgetSchema->setLabels(array(
      'username'    => 'User Name',
      'password'    => 'Password'
    ));
    
    $this->widgetSchema->setNameFormat('login[%s]');
    
    
    $this->setValidators(array( 
        'username' => new sfValidatorString( array('max_length' => 255), array('required' => 'Chưa nhập Username.')),
        'password' => new sfValidatorString(array('max_length' => 255), array('required' => 'Chưa nhập Password.'))
                                                                            
    ));
    
         /*   // Xac thuc
            $this->setValidators(array(
              'username' => new sfValidatorChoice(array('required' => true, 
                                                        'choices' => array('admin', 'administrator') )), 
              //'password' => new sfValidatorChoice(array('required' => true, 'choices' => array('password')))
              'password' => new sfValidatorAnd(array(
                                    new sfValidatorChoice(array('required' => true, 'choices' => array('password','administrator'))),
                                    new sfValidatorString(array('min_length' => 4, 'max_length' => 20),
                                                            array(
                                                                'required'   => 'Please provide a message',
                                                                'min_length' => 'Please provide a longer message (at least 4 characters)'
                                                              )),
                                  )),
              ));
         */ 
         
 
  }
}
